//
//  DealCell.m
//  ieGou
//
//  Created by 潮汐 on 15-1-28.
//  Copyright (c) 2015年 chaox. All rights reserved.
//

#import "DealCell.h"
#import "LGClient.h"
#import "UIImageView+WebCache.h"
#import "UIButton+WebCache.h"

@implementation DealCell 

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        NetWorkRequest *netWork = [[NetWorkRequest alloc]init];
//        netWork.delegate = self;
  
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.button1.tag = 1;
        [self.button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.button1];
        
        self.button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.button2.tag = 2;
        [self.button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//        self.button2.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:self.button2];
        
        self.button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.button3.tag = 3;
        [self.button3 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//        self.button3.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:self.button3];
        
        self.button4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.button4.tag = 4;
        [self.button4 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//        self.button4.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.button4];
        
        
        
        NSString *str1 = @"http://t1.dpfile.com/pc/mc/fee45997b9b98169fea69371b48005c2(640x1024)/thumb.jpg";
        NSString *str2 = @"http://t2.dpfile.com/pc/mc/bcfb5945f5f72a08b281d23b0bbf011a(450x1024)/thumb.jpg";
        NSString *str3 = @"http://t3.dpfile.com/pc/mc/6fe6aaaf0da1b4b7b2f28e69cc24a076(640x1024)/thumb.jpg";
        NSString *str4 = @"http://t1.dpfile.com/pc/mc/820eefc4535788583c7921acd696a9e4(640x1024)/thumb.jpg";
        str1 = [str1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        str2 = [str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        str3 = [str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        str4 = [str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSURL *url1 = [NSURL URLWithString:str1];
        [self.button1 setBackgroundImageWithURL:url1 forState:UIControlStateNormal];
        NSURL *url2 = [NSURL URLWithString:str2];
        [self.button2 setBackgroundImageWithURL:url2 forState:UIControlStateNormal];
        NSURL *url3 = [NSURL URLWithString:str3];
        [self.button3 setBackgroundImageWithURL:url3 forState:UIControlStateNormal];
        NSURL *url4 = [NSURL URLWithString:str4];
        [self.button4 setBackgroundImageWithURL:url4 forState:UIControlStateNormal];
        
    }
    return self;
}


-(void)layoutSubviews
{
    self.button1.frame = CGRectMake(10, 0, 172, 99);
    self.button2.frame = CGRectMake(192, 0, 168, 99);
    self.button3.frame = CGRectMake(10, 90, 172, 99);
    self.button4.frame = CGRectMake(192, 90, 168, 99);
}

-(void)buttonAction:(UIButton *)sender
{
    NSLog(@"%ld",sender.tag);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)dealloc
{
    [_button1 release];
    [_button2 release];
    [_button3 release];
    [_button4 release];
    [super dealloc];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
